load("cc_test.bzl", "cc_test")

cc_test(
    name = "alg-des",
    size = "small",
    srcs = [
        "alg-des.c",
        "des-cases.h",
    ],
    copts = ["-Ilib"],
    tags = ["unit"],
    deps = ["//lib:test"],
)

[
    cc_test(
        name = src.removesuffix(".c"),
        size = "small",
        srcs = [src],
        copts = ["-Ilib"],
        tags = ["unit"],
        deps = ["//lib:test"],
    )
    for src in (
        "alg-gost3411-2012.c",
        "alg-gost3411-2012-hmac.c",
        "alg-hmac-sha1.c",
        "alg-md4.c",
        "alg-md5.c",
        "alg-pbkdf-hmac-sha256.c",
        "alg-sha1.c",
        "alg-sha256.c",
        "alg-sha512.c",
        "alg-yescrypt.c",
        "badsalt.c",
        "badsetting.c",
        "compile-strong-alias.c",
        "crypt-badargs.c",
        "explicit-bzero.c",
        "gensalt.c",
        "gensalt-extradata.c",
        "gensalt-nthash.c",
        "getrandom-fallbacks.c",
        "getrandom-interface.c",
        "preferred-method.c",
        "short-outbuf.c",
        "special-char-salt.c",
    )
]

test_suite(
    name = "unit",
    tags = ["unit"],
)

[
    cc_test(
        name = "ka-{}".format(algo),
        size = "small",
        srcs = [
            "ka-table.inc",
            "ka-tester.c",
        ],
        copts = ["-Ilib"],
        local_defines = ["TEST_{}".format(algo)],
        tags = ["known-answers"],
        deps = ["//lib:test"],
    )
    for algo in (
        "bcrypt",
        "bcrypt_a",
        "bcrypt_x",
        "bcrypt_y",
        "bigcrypt",
        "bsdicrypt",
        "descrypt",
        "gost_yescrypt",
        "md5crypt",
        "nt",
        "scrypt",
        "sha1crypt",
        "sha256crypt",
        "sha512crypt",
        "sunmd5",
        "yescrypt",
    )
]

test_suite(
    name = "known-answers",
    tags = ["known-answers"],
)
